package com.markan.property;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * properties 파일을 읽어온다.
 * @author markan
 *
 */
public class MknPropertyService {
	
	private static MknPropertyService mknPropertyService = new MknPropertyService();
	private Properties properties;
	
	/**
	 * 초기화
	 */
	private MknPropertyService() {
		properties = new Properties();
	    try {
	        properties.load(new FileInputStream("WEB-INF/globals.properties"));
	       // properties.list(System.out);
	    } catch (FileNotFoundException e) {
	        e.printStackTrace();
	    } catch (IOException e) {
	        e.printStackTrace();
	    }
//	    Map<String, String> privacyKorMap = new HashMap<String, String>();
//	    privacyKorMap.put("SECRET", "비공개");
	}
	
	/**
	 * 싱글톤
	 * @return
	 */
	public static MknPropertyService getInstance() {
		return mknPropertyService;
	}
	
	public String getString(String key) {
		return properties.getProperty(key);
	}
	
	public String getString(String key, String defaultValue) {
		return properties.getProperty(key, defaultValue);
	}
	
}
